﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ExplorerInfrastructure;

namespace BaseTypesLib.UiTypeEditors
{
    public partial class FontControl : UserControl
    {
        public FontControl(Model.Fonts.Font font)
        {
            InitializeComponent();
            InitWithFont(font);
        }

        private void InitWithFont(Model.Fonts.Font font)
        {
            if (font == null)
            {
                cbStyle.SelectedIndex = 0;
                nudSize.Value = ProjectInfo.GetInstance().FontSize;
                return;
            }
            nudSize.Value = font.Height;
            cbStyle.SelectedItem = font.Style.ToString();
        }

        public Model.Fonts.Font GetFont()
        {
            if (chkClear.Checked)
                return null;
            return new Model.Fonts.Font()
            {
                Height = (int)nudSize.Value,
                Style = (Model.Fonts.FieldFontStyle)Enum.Parse(typeof(Model.Fonts.FieldFontStyle), cbStyle.SelectedItem.ToString())
            };
        }
    }
}
